import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    dataIndex: 'projectId_dictText'
  },
  {
    title: '供应商',
    align: "center",
    dataIndex: 'supplierId_dictText'
  },
  {
    title: '外包人员',
    align: "center",
    dataIndex: 'userId'
  },
  {
    title: '开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'endDate'
  },
  {
    title: '项目经理',
    align: "center",
    dataIndex: 'projectManager_dictText'
  },
  {
    title: '项目负责人',
    align: "center",
    dataIndex: 'projectOwner_dictText'
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'comments'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '供应商',
    field: 'supplierId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_supplier_manage,supplier_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入供应商!'},
             ];
    },
  },
  {
    label: '外包人员',
    field: 'userId',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入外包人员!'},
             ];
    },
  },
  {
    label: '开始时间',
    field: 'startDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入开始时间!'},
             ];
    },
  },
  {
    label: '结束时间',
    field: 'endDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入结束时间!'},
             ];
    },
  },
  {
    label: '项目经理',
    field: 'projectManager',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
  },
  {
    label: '项目负责人',
    field: 'projectOwner',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
  },
  {
    label: '备注',
    field: 'comments',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'list', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  supplierId: {title: '供应商',order: 1,view: 'list', type: 'string',dictTable: "tm_supplier_manage", dictCode: 'id', dictText: 'supplier_name',},
  userId: {title: '外包人员',order: 2,view: 'text', type: 'string',},
  startDate: {title: '开始时间',order: 3,view: 'date', type: 'string',},
  endDate: {title: '结束时间',order: 4,view: 'datetime', type: 'string',},
  projectManager: {title: '项目经理',order: 5,view: 'sel_user', type: 'string',},
  projectOwner: {title: '项目负责人',order: 6,view: 'sel_user', type: 'string',},
  comments: {title: '备注',order: 7,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 8,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 9,view: 'datetime', type: 'string',},
};
